OBJECT Table 50010 Event Log Arguments
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=23:40:36;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Event Log Arguments;
  }
  FIELDS
  {
    { 1   ;   ;Type                ;Option        ;CaptionML=ENU=Type;
                                                   OptionCaptionML=ENU=Info,Warning,Error;
                                                   OptionString=Info,Warning,Error }
    { 2   ;   ;Source              ;Text250       ;CaptionML=ENU=Source }
    { 3   ;   ;Message             ;Text250       ;CaptionML=ENU=Message }
  }
  KEYS
  {
    {    ;Type                                    ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
    END.
  }
}

OBJECT Table 50029 Event Log Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=15:30:09;
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
  }
  FIELDS
  {
    { 1   ;   ;Primary Key         ;Code10         }
    { 2   ;   ;Event Logging Codeunit No.;Integer ;TableRelation=AllObjWithCaption."Object ID" WHERE (Object Type=CONST(Codeunit)) }
  }
  KEYS
  {
    {    ;Primary Key                             ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
    END.
  }
}

OBJECT Table 50060 Interface Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:42:17;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Interface Setup;
  }
  FIELDS
  {
    { 1   ;   ;Interface Name      ;Text200       ;CaptionML=ENU=Interface Name;
                                                   Editable=No }
    { 2   ;   ;Module Name         ;Text200       ;CaptionML=ENU=Module Name }
    { 3   ;   ;Configuration Page ID;Integer       }
  }
  KEYS
  {
    {    ;Interface Name                          ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    PROCEDURE RegisterInterface@3(InterfaceName@1000 : Text);
    VAR
      Setup@1001 : Record 50060;
    BEGIN
      Setup."Interface Name" := InterfaceName;
      IF Setup.FIND THEN
        EXIT
      ELSE
        Setup.INSERT;
    END;

    [Integration]
    PROCEDURE OnRegisterInterface@1(InterfaceSetup@1000 : Record 50060);
    BEGIN
    END;

    BEGIN
    END.
  }
}

OBJECT Table 50061 Interface Module
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:46:14;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Interface Setup;
  }
  FIELDS
  {
    { 1   ;   ;Interface Name      ;Text200       ;CaptionML=ENU=Interface Name }
    { 2   ;   ;Module Name         ;Text200       ;CaptionML=ENU=Module Name }
    { 3   ;   ;Configuration Page ID;Integer       }
  }
  KEYS
  {
    {    ;Interface Name,Module Name              ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    PROCEDURE RegisterModule@2(InterfaceName@1000 : Text;ModuleName@1001 : Text;PageID@1002 : Integer);
    BEGIN
      "Interface Name" := InterfaceName;
      "Module Name" := ModuleName;
      "Configuration Page ID" := PageID;
      IF NOT FIND THEN
        INSERT;
    END;

    [Integration]
    PROCEDURE OnRegisterModule@4(InterfaceName@1001 : Text;VAR InterfaceModule@1000 : Record 50061);
    BEGIN
    END;

    BEGIN
    END.
  }
}

OBJECT Table 50082 Event Log - File Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:52:28;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Event Log - File Setup;
  }
  FIELDS
  {
    { 1   ;   ;Primary Key         ;Code10        ;CaptionML=ENU=Primary Key }
    { 2   ;   ;Log File Path       ;Text250       ;CaptionML=ENU=Log File Path }
  }
  KEYS
  {
    {    ;Primary Key                             ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
    END.
  }
}

OBJECT Table 50084 Event Log - Twitter Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:13:04;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Event Log - Twitter Setup;
  }
  FIELDS
  {
    { 1   ;   ;Primary Key         ;Code10        ;CaptionML=ENU=Primary Key }
    { 2   ;   ;Consumer Key        ;Text200       ;CaptionML=ENU=Consumer Key }
    { 3   ;   ;Consumer Key Secret ;Text200       ;ExtendedDatatype=Masked;
                                                   CaptionML=ENU=Consumer Key Secret }
    { 4   ;   ;Access Token        ;Text200       ;CaptionML=ENU=Access Token }
    { 5   ;   ;Access Token Secret ;Text200       ;ExtendedDatatype=Masked;
                                                   CaptionML=ENU=Access Token Secret }
  }
  KEYS
  {
    {    ;Primary Key                             ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
    END.
  }
}

OBJECT Codeunit 50010 Event Log - Old School
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=23:43:19;
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {

    PROCEDURE LogFileSystem@5(EventSource@1001 : Text;EventMessage@1002 : Text);
    VAR
      Setup@1003 : Record 50082;
      File@1004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
      Environment@1005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      EntryLine@1006 : TextConst 'ENU=%1 %2 %3%4';
    BEGIN
      IF NOT Setup.GET OR (Setup."Log File Path" = '') THEN
        EXIT;

      File.AppendAllText(
        Setup."Log File Path",
        STRSUBSTNO(
          EntryLine,
          CURRENTDATETIME,
          PADSTR(EventSource,20),
          EventMessage,
          Environment.NewLine));
    END;

    PROCEDURE LogEventLog@3(EventType@1000 : 'Info,Warning,Error';EventSource@1001 : Text;EventMessage@1002 : Text);
    VAR
      EventLog@1003 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLog";
      EntryType@1004 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLogEntryType";
      EventEntryText@1006 : TextConst 'ENU=Source: %1\Message: %2';
      EventLogSource@1005 : TextConst 'ENU=MicrosoftDynamicsNavServer';
      Env@1008 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      String@1007 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String";
    BEGIN
      EntryType := EntryType.Information;

      CASE EventType OF
        EventType::Warning: EntryType := EntryType.Warning;
        EventType::Error:   EntryType := EntryType.Error;
      END;

      String := STRSUBSTNO(EventEntryText,EventSource,EventMessage);
      EventMessage := String.Replace('\',Env.NewLine);

      EventLog := EventLog.EventLog();
      EventLog.WriteEntry(EventLogSource,EventMessage,EntryType);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50011 Event Log - Argument Table
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:13:39];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {

    PROCEDURE LogFileSystem@5(VAR EventLogArgs@1000 : Record 50010);
    VAR
      Setup@1003 : Record 50082;
      File@1004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
      Environment@1005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      EntryLine@1006 : TextConst 'ENU=%1 %2 %3%4';
    BEGIN
      IF NOT Setup.GET OR (Setup."Log File Path" = '') THEN
        EXIT;

      File.AppendAllText(
        Setup."Log File Path",
        STRSUBSTNO(
          EntryLine,
          CURRENTDATETIME,
          PADSTR(EventLogArgs.Source,20),
          EventLogArgs.Message,
          Environment.NewLine));
    END;

    PROCEDURE LogEventLog@3(VAR EventLogArgs@1000 : Record 50010);
    VAR
      EventLog@1003 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLog";
      EntryType@1004 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLogEntryType";
      EventEntryText@1006 : TextConst 'ENU=Source: %1\Message: %2';
      EventLogSource@1005 : TextConst 'ENU=MicrosoftDynamicsNavServer';
      Env@1008 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      String@1007 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String";
      EventMessage@1001 : Text;
    BEGIN
      EntryType := EntryType.Information;

      CASE EventLogArgs.Type OF
        EventLogArgs.Type::Warning: EntryType := EntryType.Warning;
        EventLogArgs.Type::Error:   EntryType := EntryType.Error;
      END;

      String := STRSUBSTNO(EventEntryText,EventLogArgs.Source,EventLogArgs.Message);
      EventMessage := String.Replace('\',Env.NewLine);

      EventLog := EventLog.EventLog();
      EventLog.WriteEntry(EventLogSource,EventMessage,EntryType);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50012 Event Log Call - Old School
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=23:50:16;
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            EventLog.LogFileSystem(
              'Sales',
              'Sales Order 1000 has just been released.');
          END;

  }
  CODE
  {
    VAR
      EventLog@1000 : Codeunit 50010;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50013 Event Log Call - Argument Tbl.
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:03:29];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            Args.Type := Args.Type::Info;
            Args.Source := 'Sales';
            Args.Message := 'Sales Order 1000 has just been released.';

            // I can now call this:
            EventLog.LogFileSystem(Args);

            // ... but also this:
            EventLog.LogEventLog(Args);
          END;

  }
  CODE
  {
    VAR
      Args@1001 : Record 50010;
      EventLog@1000 : Codeunit 50011;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50014 Event Log - File (Arg. Tbl.)
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:14:10];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    TableNo=50010;
    OnRun=BEGIN
            IF NOT Setup.GET OR (Setup."Log File Path" = '') THEN
              EXIT;

            IOFile.AppendAllText(
              Setup."Log File Path",
              STRSUBSTNO(
                EntryLine,
                CURRENTDATETIME,
                PADSTR(Rec.Source,20),
                Rec.Message,
                Environment.NewLine));
          END;

  }
  CODE
  {
    VAR
      Setup@1002 : Record 50082;
      IOFile@1001 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
      Environment@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      EntryLine@1003 : TextConst 'ENU=%1 %2 %3%4';

    BEGIN
    END.
  }
}

OBJECT Codeunit 50015 Event Log - Event Log (Arg.)
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:15:40];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    TableNo=50010;
    OnRun=BEGIN
            EntryType := EntryType.Information;

            CASE Rec.Type OF
              Rec.Type::Warning: EntryType := EntryType.Warning;
              Rec.Type::Error:   EntryType := EntryType.Error;
            END;

            String := STRSUBSTNO(EventEntryText,Rec.Source,Rec.Message);
            EventMessage := String.Replace('\',Env.NewLine);

            EventLog := EventLog.EventLog();
            EventLog.WriteEntry(EventLogSource,EventMessage,EntryType);
          END;

  }
  CODE
  {
    VAR
      EventEntryText@1001 : TextConst 'ENU=Source: %1\Message: %2';
      EventLogSource@1000 : TextConst 'ENU=MicrosoftDynamicsNavServer';
      EventLog@1006 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLog";
      EntryType@1005 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLogEntryType";
      Env@1004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      String@1003 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String";
      EventMessage@1002 : Text;

    EVENT EventLog@1006::EntryWritten@60(sender@1001 : Variant;e@1000 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EntryWrittenEventArgs");
    BEGIN
    END;

    EVENT EventLog@1006::Disposed@61(sender@1001 : Variant;e@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.EventArgs");
    BEGIN
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50016 Event Log Call - Arg. Tbl. CU
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:16:55];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            Args.Type := Args.Type::Info;
            Args.Source := 'Sales';
            Args.Message := 'Sales Order 1000 has just been released.';

            // I can now call this:
            CODEUNIT.RUN(CODEUNIT::"Event Log - File (Arg. Tbl.)",Args);

            // ... but also this:
            CODEUNIT.RUN(CODEUNIT::"Event Log - Event Log (Arg.)",Args);
          END;

  }
  CODE
  {
    VAR
      Args@1001 : Record 50010;
      EventLog@1000 : Codeunit 50011;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50020 Event Log - Facade
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:25:13];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ErrorNoCodeunitConfiguration@1000 : TextConst 'ENU=No event logging codeunit found.';

    PROCEDURE LogEvent@1(VAR EventArgs@1000 : Record 50010);
    VAR
      CodeunitID@1001 : Integer;
    BEGIN
      IF NOT FindCodeunitByUser(CodeunitID) THEN
        IF NOT FindDefaultCodeunit(CodeunitID) THEN
          ThrowError();

      CODEUNIT.RUN(CodeunitID,EventArgs);
    END;

    LOCAL PROCEDURE FindCodeunitByUser@2(VAR CodeunitID@1000 : Integer) : Boolean;
    BEGIN
      IF UserSetup.GET(USERID) AND (UserSetup."Event Log Codeunit ID" <> 0) THEN BEGIN
        CodeunitID := UserSetup."Event Log Codeunit ID");
        EXIT(TRUE);
      END;
    END;

    LOCAL PROCEDURE FindDefaultCodeunit@3(VAR CodeunitID@1000 : Integer) : Boolean;
    BEGIN
      IF EventLogSetup.GET AND EventLogSetup."Event Log Codeunit ID" <> 0) THEN BEGIN
        CodeunitID := EventLogSetup."Event Log Codeunit ID";
        EXIT(TRUE);
      END;
    END;

    LOCAL PROCEDURE ThrowError@4();
    BEGIN
      ERROR(ErrorNoCodeunitConfiguration);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50021 Event Log Call - Facade
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:25:19];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            Args.Type := Args.Type::Info;
            Args.Source := 'Sales';
            Args.Message := 'Sales Order 1000 has just been released.';

            EventLogFacade.LogEvent(Args);
          END;

  }
  CODE
  {
    VAR
      Args@1001 : Record 50010;
      EventLogFacade@1000 : Codeunit 50020;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50030 Event Log - Variant Facade
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:39:23];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ErrorNoCodeunitConfiguration@1000 : TextConst 'ENU=No event logging codeunit found.';

    PROCEDURE LogEvent@1(VAR EventArgs@1000 : Record 50010;Entity@1002 : Variant);
    VAR
      CodeunitID@1001 : Integer;
    BEGIN
      IF NOT FindCodeunitByUser(CodeunitID) THEN
        IF NOT FindDefaultCodeunit(CodeunitID) THEN
          ThrowError();

      PrepareMessage(Entity,EventArgs.Message);

      CODEUNIT.RUN(CodeunitID,EventArgs);
    END;

    LOCAL PROCEDURE PrepareMessage@5(Entity@1000 : Variant;VAR Msg@1002 : Text);
    VAR
      RecRef@1001 : RecordRef;
      Cust@1003 : Record 18;
      Vend@1004 : Record 23;
    BEGIN
      RecRef.GETTABLE(Entity);
      CASE RecRef.NUMBER OF
        DATABASE::Customer:
          BEGIN
            RecRef.SETTABLE(Cust);
            Msg := STRSUBSTNO('%1 %2 %3',Msg,Cust.TABLECAPTION,Cust.Name);
          END;
        DATABASE::Vendor:
          BEGIN
            RecRef.SETTABLE(Vend);
            Msg := STRSUBSTNO('%1 %2 %3',Msg,Vend.TABLECAPTION,Vend.Name);
          END;
      END;
    END;

    LOCAL PROCEDURE FindCodeunitByUser@2(VAR CodeunitID@1000 : Integer) : Boolean;
    BEGIN
      IF UserSetup.GET(USERID) AND (UserSetup."Event Log Codeunit ID" <> 0) THEN BEGIN
        CodeunitID := UserSetup."Event Log Codeunit ID");
        EXIT(TRUE);
      END;
    END;

    LOCAL PROCEDURE FindDefaultCodeunit@3(VAR CodeunitID@1000 : Integer) : Boolean;
    BEGIN
      IF EventLogSetup.GET AND EventLogSetup."Event Log Codeunit ID" <> 0) THEN BEGIN
        CodeunitID := EventLogSetup."Event Log Codeunit ID";
        EXIT(TRUE);
      END;
    END;

    LOCAL PROCEDURE ThrowError@4();
    BEGIN
      ERROR(ErrorNoCodeunitConfiguration);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50031 Event Log Call - Var. Facade
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:44:46];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
            // For customer
            Args.Type := Args.Type::Info;
            Args.Source := 'Sales';
            Args.Message := STRSUBSTNO(
              'Sales Order %1 has just been released.',
              SalesHeader."No.");

            Cust.GET(SalesHeader."Sell-to Customer No.");
            EventLogVariantFacade.LogEvent(Args,Cust);

            // For vendor
            Args.Type := Args.Type::Info;
            Args.Source := 'Purchases';
            Args.Message := STRSUBSTNO(
              'Purchase Order %1 has just been released.',
              PurchHeader."No.");

            Vend.GET(PurchHeader."Bill-to Vendor No.");
            EventLogVariantFacade.LogEvent(Args,Vend);
          END;

  }
  CODE
  {
    VAR
      Args@1001 : Record 50010;
      EventLogVariantFacade@1000 : Codeunit 50030;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50040 Event Log - TempBlob Facade
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:54:42];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    TableNo=99008535;
    OnRun=BEGIN
            IF NOT FindCodeunitByUser(CodeunitID) THEN
              IF NOT FindDefaultCodeunit(CodeunitID) THEN
                ThrowError();

            TempBlobMgt.TempBlobToObject(Rec,Dict);

            EVALUATE(Args.Type,Dict.Item('Type'));
            Args.Source := Dict.Item('Source');
            Args.Message := Dict.Item('Message');

            CODEUNIT.RUN(CodeunitID,EventArgs);
          END;

  }
  CODE
  {
    VAR
      Args@1002 : Record 50010;
      TempBlobMgt@1000 : Codeunit 50049;
      Dict@1001 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Generic.Dictionary`2";

    BEGIN
    END.
  }
}

OBJECT Codeunit 50041 Event Log Call - TempBlob Fac.
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 0:54:57];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=VAR
            TempBlobMgt@1002 : Codeunit 50049;
            Dict@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Generic.Dictionary`2";
            Blob@1001 : Record 99008535;
          BEGIN
            Dict := Dict.Dictionary();
            Dict.Add('Type','Info');
            Dict.Add('Source','Sales');
            Dict.Add('Message','Sales Order 1001 has just been released.');

            TempBlobMgt.ObjectToTempBlob(Dict,Blob);
            CODEUNIT.RUN(CODEUNIT::"Event Log - TempBlob Facade",Blob);
          END;

  }
  CODE
  {

    BEGIN
    END.
  }
}

OBJECT Codeunit 50049 TempBlob Management
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=10:59:12;
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {

    PROCEDURE ObjectToTempBlob@7(Object@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Object";VAR TempBlob@1001 : Record 99008535);
    VAR
      OutStream@1003 : OutStream;
      Json@1002 : Text;
    BEGIN
      CLEAR(TempBlob);

      ObjectToJson(Object,Json);
      TempBlob.Blob.CREATEOUTSTREAM(OutStream);
      TextToStream(Json,OutStream);
    END;

    PROCEDURE TempBlobToObject@2(TempBlob@1001 : Record 99008535;VAR Object@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Object");
    VAR
      InStream@1002 : InStream;
      JSON@1003 : Text;
    BEGIN
      TempBlob.Blob.CREATEINSTREAM(InStream);
      StreamToText(InStream,JSON);
      JsonToObject(Object,JSON);
    END;

    PROCEDURE ObjectToJson@5(Object@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Object";VAR JSON@1001 : Text);
    VAR
      JS@1002 : DotNet "'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.System.Web.Script.Serialization.JavaScriptSerializer";
    BEGIN
      JS := JS.JavaScriptSerializer();
      JSON := JS.Serialize(Object);
    END;

    PROCEDURE JsonToObject@4(VAR Object@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Object";JSON@1001 : Text);
    VAR
      JS@1002 : DotNet "'System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.System.Web.Script.Serialization.JavaScriptSerializer";
    BEGIN
      JS := JS.JavaScriptSerializer();
      Object := JS.DeserializeObject(JSON);
    END;

    PROCEDURE TextToStream@1(Text@1000 : Text;Stream@1001 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Stream");
    VAR
      Writer@1002 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.StreamWriter";
    BEGIN
      Writer := Writer.StreamWriter(Stream);
      Writer.Write(Text);
      Writer.Close();
    END;

    LOCAL PROCEDURE StreamToText@8(Stream@1000 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.Stream";VAR Text@1002 : Text) : Text;
    VAR
      Reader@1001 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.StreamReader";
    BEGIN
      Reader := Reader.StreamReader(Stream);
      Text := Reader.ReadToEnd();
      Reader.Close();
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50050 Event Log - Handled
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 1:54:36];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {

    PROCEDURE LogEvent@2(VAR EventArgs@1000 : Record 50010);
    VAR
      Handled@1001 : Boolean;
      CodeunitID@1002 : Integer;
      ErrorNotHandled@1003 : TextConst 'ENU=LogEvent event was not handled by any of loosely-coupled codeunits.';
    BEGIN
      // Retrieve handler identifier
      GetHandler(CodeunitID);

      // Call event
      OnLogEvent(CodeunitID,EventArgs,Handled);

      // Make sure event was handled
      IF NOT Handled THEN
        ERROR(ErrorNotHandled);
    END;

    [Integration]
    LOCAL PROCEDURE OnLogEvent@3(HandlerCodeunit@1002 : Integer;VAR EventArgs@1000 : Record 50010;VAR Handled@1001 : Boolean);
    BEGIN
    END;

    LOCAL PROCEDURE GetHandler@4(VAR CodeunitID@1000 : Integer);
    BEGIN
      IF EventLogSetup.GET AND (EventLogSetup."Event Log Handler Codeunit" <> 0) THEN
        CodeunitID := EventLogSetup."Event Log Handler Codeunit";
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50051 Event Log - Handled File
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 1:57:28];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50050,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@1(HandlerCodeunit@1000 : Integer;VAR EventArgs@1001 : Record 50010;VAR Handled@1002 : Boolean);
    VAR
      Setup@1005 : Record 50082;
      File@1004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
      Environment@1003 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      EntryLine@1006 : TextConst 'ENU=%1 %2 %3%4';
    BEGIN
      IF Handled OR (HandlerCodeunit <> CODEUNIT::"Event Log - Handled File") THEN
        EXIT;

      IF NOT Setup.GET OR (Setup."Log File Path" = '') THEN
        EXIT;

      File.AppendAllText(
        Setup."Log File Path",
        STRSUBSTNO(
          EntryLine,
          CURRENTDATETIME,
          PADSTR(EventArgs.Source,20),
          EventArgs.Message,
          Environment.NewLine));

      Handled := TRUE;
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50052 Event Log - Handled Event Log
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 2:17:11];
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50050,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@1(HandlerCodeunit@1000 : Integer;VAR EventArgs@1001 : Record 50010;VAR Handled@1002 : Boolean);
    VAR
      EventLog@1007 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLog";
      EntryType@1006 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLogEntryType";
      Env@1005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      String@1004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String";
      EventMessage@1003 : Text;
      EventEntryText@1009 : TextConst 'ENU=Source: %1\Message: %2';
      EventLogSource@1008 : TextConst 'ENU=MicrosoftDynamicsNavServer';
    BEGIN
      IF Handled OR (HandlerCodeunit <> CODEUNIT::"Event Log - Handled Event Log") THEN
        EXIT;

      EntryType := EntryType.Information;

      CASE EventArgs.Type OF
        EventArgs.Type::Warning: EntryType := EntryType.Warning;
        EventArgs.Type::Error:   EntryType := EntryType.Error;
      END;

      String := STRSUBSTNO(EventEntryText,EventArgs.Source,EventArgs.Message);
      EventMessage := String.Replace('\',Env.NewLine);
      EventLog := EventLog.EventLog();
      EventLog.WriteEntry(EventLogSource,EventMessage,EntryType);

      Handled := TRUE;
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50060 Module Management
{
  OBJECT-PROPERTIES
  {
    Date=28.09.16;
    Time=21:57:18;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ErrorManualSubscription@1000 : TextConst 'ENU=Event subscriptions to codeunit %1 must be manual. At least one codeunit (%2 %3) was detected with static subscription. Codeunit %1 does not allow static subscriptions.';
      ErrorNoSubscriber@1001 : TextConst 'ENU=There is no event subscriber currently listening on the %1 event from codeunit %2.';
      ErrorNoSetup@1002 : TextConst 'ENU=Interface %1 is not configured with a module that implements it. Please run the %2 page.';
      BoundModules@1003 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Collections.Generic.Dictionary`2";

    PROCEDURE BindInterface@6(InterfaceName@1000 : Text;WithError@1002 : Boolean);
    VAR
      Setup@1001 : Record 50060;
      SetupPage@1003 : Page 50060;
      Notification@1004 : Notification;
    BEGIN
      IF NOT Setup.GET(InterfaceName) THEN BEGIN
        IF WithError THEN
          ERROR(ErrorNoSetup,InterfaceName,SetupPage.CAPTION);
        MESSAGE(ErrorNoSetup,InterfaceName,SetupPage.CAPTION);
        EXIT;
      END;

      BindModule(InterfaceName,Setup."Module Name");
    END;

    PROCEDURE UnbindInterface@7(InterfaceName@1000 : Text);
    VAR
      Setup@1001 : Record 50060;
    BEGIN
      IF NOT Setup.GET(InterfaceName) THEN
        EXIT;

      UnbindModule(InterfaceName,Setup."Module Name");
    END;

    LOCAL PROCEDURE BindModule@9(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF MarkModuleBound(InterfaceName,ModuleName) THEN
        OnBindModule(InterfaceName,ModuleName);
    END;

    LOCAL PROCEDURE UnbindModule@11(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF MarkModuleUnbound(InterfaceName,ModuleName) THEN
        OnUnbindModule(InterfaceName,ModuleName);
    END;

    [TryFunction]
    PROCEDURE MakeSureSubscriptionsAreManual@4(CodeunitID@1000 : Integer);
    VAR
      Subscription@1001 : Record 2000000140;
      AllObj@1002 : Record 2000000058;
    BEGIN
      WITH Subscription DO BEGIN
        SETRANGE("Publisher Object Type","Publisher Object Type"::Codeunit);
        SETRANGE("Publisher Object ID",CodeunitID);
        SETRANGE("Subscriber Instance",'Static-Automatic');
        IF FINDFIRST THEN BEGIN
          AllObj.GET(AllObj."Object Type"::Codeunit,"Subscriber Codeunit ID");
          ERROR(ErrorManualSubscription,CodeunitID,"Subscriber Codeunit ID",AllObj."Object Caption");
        END;
      END;
    END;

    [TryFunction]
    PROCEDURE MakeSureSubscriberExists@5(CodeunitID@1002 : Integer;FunctionName@1003 : Text);
    VAR
      Subscription@1001 : Record 2000000140;
    BEGIN
      WITH Subscription DO BEGIN
        SETRANGE("Publisher Object Type","Publisher Object Type"::Codeunit);
        SETRANGE("Publisher Object ID",CodeunitID);
        SETRANGE("Published Function",FunctionName);
        SETRANGE("Subscriber Instance",'Manual');
        SETRANGE(Active,TRUE);
        SETFILTER("Active Manual Instances",'>=%1',1);
        IF ISEMPTY THEN
          ERROR(ErrorNoSubscriber,FunctionName,CodeunitID);
      END;
    END;

    LOCAL PROCEDURE MakeSureBindingsCanBeTracked@12();
    BEGIN
      IF ISNULL(BoundModules) THEN
        BoundModules := BoundModules.Dictionary();
    END;

    LOCAL PROCEDURE MarkModuleBound@3(InterfaceName@1001 : Text;ModuleName@1000 : Text) : Boolean;
    VAR
      Count@1002 : Integer;
    BEGIN
      MakeSureBindingsCanBeTracked();

      IF IsModuleBound(InterfaceName,ModuleName) THEN BEGIN
        Count := BoundModules.Item(GetModuleId(InterfaceName,ModuleName));
        Count += 1;
        BoundModules.Item(GetModuleId(InterfaceName,ModuleName),Count);
        EXIT(FALSE);
      END;

      BoundModules.Add(GetModuleId(InterfaceName,ModuleName),1);
      EXIT(TRUE);
    END;

    LOCAL PROCEDURE MarkModuleUnbound@16(InterfaceName@1001 : Text;ModuleName@1000 : Text) : Boolean;
    VAR
      Count@1002 : Integer;
    BEGIN
      MakeSureBindingsCanBeTracked();

      IF IsModuleBound(InterfaceName,ModuleName) THEN BEGIN
        Count := BoundModules.Item(GetModuleId(InterfaceName,ModuleName));
        Count -= 1;
        BoundModules.Item(GetModuleId(InterfaceName,ModuleName),Count);
        EXIT(Count = 0);
      END;
    END;

    LOCAL PROCEDURE IsModuleBound@8(InterfaceName@1001 : Text;ModuleName@1000 : Text) : Boolean;
    BEGIN
      EXIT(BoundModules.ContainsKey(GetModuleId(InterfaceName,ModuleName)));
    END;

    LOCAL PROCEDURE GetModuleId@10(InterfaceName@1001 : Text;ModuleName@1000 : Text) : Text;
    BEGIN
      EXIT(InterfaceName+ModuleName);
    END;

    [Integration]
    PROCEDURE OnBindModule@1(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
    END;

    [Integration]
    PROCEDURE OnUnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50070 Event Log Interface
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:28:28];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Event Logging';

    PROCEDURE LogEvent@2(VAR EventLogArgs@1000 : Record 50010);
    BEGIN
      IF NOT ModuleMgt.MakeSureSubscriberExists(CODEUNIT::"Event Log Interface",'OnLogEvent') THEN BEGIN
        MESSAGE(GETLASTERRORTEXT);
        EXIT;
      END;

      OnLogEvent(EventLogArgs);
    END;

    [Integration]
    PROCEDURE OnLogEvent@5(VAR EventLogArgs@1003 : Record 50010);
    BEGIN
    END;

    [EventSubscriber(Codeunit,1,OnAfterCompanyOpen)]
    LOCAL PROCEDURE OnCompanyOpen@1();
    BEGIN
      ModuleMgt.MakeSureSubscriptionsAreManual(CODEUNIT::"Event Log Interface");
    END;

    [EventSubscriber(Table,50060,OnRegisterInterface)]
    LOCAL PROCEDURE OnRegisterInterface@3(InterfaceSetup@1000 : Record 50060);
    BEGIN
      InterfaceSetup.RegisterInterface(InterfaceName);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50071 Event Logger
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:20:28];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Event Logging';
      Log@1002 : Codeunit 50070;
      SourceSales@1003 : TextConst 'ENU=Sales';
      EventReleased@1004 : TextConst 'ENU=Sales %1 %2 has just been released.';
      EventReopened@1005 : TextConst 'ENU=Sales %1 %2 has just been reopened.';

    [EventSubscriber(Page,42,OnOpenPageEvent)]
    LOCAL PROCEDURE SalesOrder_Open@2(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.BindInterface(InterfaceName,FALSE);
    END;

    [EventSubscriber(Page,42,OnClosePageEvent)]
    LOCAL PROCEDURE SalesOrder_Close@3(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.UnbindInterface(InterfaceName);
    END;

    [EventSubscriber(Page,9305,OnOpenPageEvent)]
    LOCAL PROCEDURE SalesOrderList_Open@4(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.BindInterface(InterfaceName,FALSE);
    END;

    [EventSubscriber(Page,9305,OnClosePageEvent)]
    LOCAL PROCEDURE SalesOrderList_Close@1(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.UnbindInterface(InterfaceName);
    END;

    [EventSubscriber(Page,48,OnOpenPageEvent)]
    LOCAL PROCEDURE SalesOrders_Open@8(VAR Rec@1000 : Record 37);
    BEGIN
      ModuleMgt.BindInterface(InterfaceName,FALSE);
    END;

    [EventSubscriber(Page,48,OnClosePageEvent)]
    LOCAL PROCEDURE SalesOrders_Close@7(VAR Rec@1000 : Record 37);
    BEGIN
      ModuleMgt.UnbindInterface(InterfaceName);
    END;

    [EventSubscriber(Codeunit,414,OnAfterReleaseSalesDoc)]
    LOCAL PROCEDURE SalesOrder_Released@5(VAR SalesHeader@1000 : Record 36);
    VAR
      Args@1001 : Record 50010;
    BEGIN
      CreateEventArgs(Args,0,SourceSales,STRSUBSTNO(EventReleased,SalesHeader."Document Type",SalesHeader."No."));
      Log.LogEvent(Args);
    END;

    [EventSubscriber(Codeunit,414,OnAfterReopenSalesDoc)]
    LOCAL PROCEDURE SalesOrder_Reopened@6(VAR SalesHeader@1000 : Record 36);
    VAR
      Args@1001 : Record 50010;
    BEGIN
      CreateEventArgs(Args,0,SourceSales,STRSUBSTNO(EventReopened,SalesHeader."Document Type",SalesHeader."No."));
      Log.LogEvent(Args);
    END;

    LOCAL PROCEDURE CreateEventArgs@9(VAR EventArgs@1000 : Record 50010;Type@1001 : Option;Source@1002 : Text;Msg@1003 : Text);
    BEGIN
      CLEAR(EventArgs);
      EventArgs.Type := Type;
      EventArgs.Source := Source;
      EventArgs.Message := Msg;
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50072 Address Formatter Interface
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=22:48:34;
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Address Formatter';

    PROCEDURE FormatAddress@2();
    BEGIN
      IF NOT ModuleMgt.MakeSureSubscriberExists(CODEUNIT::"Address Formatter Interface",'OnFormatAddress') THEN BEGIN
        MESSAGE(GETLASTERRORTEXT);
        EXIT;
      END;

      OnFormatAddress();
    END;

    [Integration]
    PROCEDURE OnFormatAddress@5();
    BEGIN
      // This is just for demonstration purposes, and intentionally does nothing.
    END;

    [EventSubscriber(Codeunit,1,OnAfterCompanyOpen)]
    LOCAL PROCEDURE OnCompanyOpen@1();
    BEGIN
      ModuleMgt.MakeSureSubscriptionsAreManual(CODEUNIT::"Address Formatter Interface");
    END;

    [EventSubscriber(Table,50060,OnRegisterInterface)]
    LOCAL PROCEDURE OnRegisterInterface@3(InterfaceSetup@1000 : Record 50060);
    BEGIN
      InterfaceSetup.RegisterInterface(InterfaceName);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50073 Currency Exchange Interface
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=22:49:50;
    Modified=Yes;
    Version List=Directions.2017;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Currency Exchange';

    PROCEDURE ExchangeCurrency@2();
    BEGIN
      IF NOT ModuleMgt.MakeSureSubscriberExists(CODEUNIT::"Currency Exchange Interface",'OnExchangeCurrency') THEN BEGIN
        MESSAGE(GETLASTERRORTEXT);
        EXIT;
      END;

      OnExchangeCurrency();
    END;

    [Integration]
    PROCEDURE OnExchangeCurrency@5();
    BEGIN
      // This is just for demonstration purposes, and intentionally does nothing.
    END;

    [EventSubscriber(Codeunit,1,OnAfterCompanyOpen)]
    LOCAL PROCEDURE OnCompanyOpen@1();
    BEGIN
      ModuleMgt.MakeSureSubscriptionsAreManual(CODEUNIT::"Currency Exchange Interface");
    END;

    [EventSubscriber(Table,50060,OnRegisterInterface)]
    LOCAL PROCEDURE OnRegisterInterface@3(InterfaceSetup@1000 : Record 50060);
    BEGIN
      InterfaceSetup.RegisterInterface(InterfaceName);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50080 Event Log Binder - Windows
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:21:18;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SingleInstance=Yes;
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      Module@1000 : Codeunit 50081;
      Name@1001 : TextConst 'ENU=Windows Event Log';
      ImplementsInterface@1003 : TextConst 'ENU=Event Logging';

    [EventSubscriber(Codeunit,50060,OnBindModule)]
    LOCAL PROCEDURE BindModule@1(InterfaceName@1002 : Text;ModuleName@1001 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      CLEAR(Module);
      BINDSUBSCRIPTION(Module);
    END;

    [EventSubscriber(Codeunit,50060,OnUnbindModule)]
    LOCAL PROCEDURE UnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      UNBINDSUBSCRIPTION(Module);
      CLEAR(Module);
    END;

    [EventSubscriber(Table,50061,OnRegisterModule)]
    LOCAL PROCEDURE OnRegisterModule@3(InterfaceName@1000 : Text;VAR InterfaceModule@1001 : Record 50061);
    BEGIN
      IF InterfaceName = ImplementsInterface THEN
        InterfaceModule.RegisterModule(InterfaceName,Name,0);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50081 Event Log - Windows
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:21:52];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    EventSubscriberInstance=Manual;
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50070,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@2(VAR EventLogArgs@1007 : Record 50010);
    VAR
      EventLog@1003 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLog";
      EntryType@1004 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLogEntryType";
      EventEntryText@1006 : TextConst 'ENU=Source: %1\Message: %2';
      EventLogSource@1005 : TextConst 'ENU=MicrosoftDynamicsNavServer';
    BEGIN
      EntryType := EntryType.Information;

      CASE EventLogArgs.Type OF
        EventLogArgs.Type::Warning: EntryType := EntryType.Warning;
        EventLogArgs.Type::Error:   EntryType := EntryType.Error;
      END;
      EventLog := EventLog.EventLog();
      EventLog.WriteEntry(
        EventLogSource,
        GetLogMessage(STRSUBSTNO(EventEntryText,EventLogArgs.Source,EventLogArgs.Message)),
        EntryType);
    END;

    LOCAL PROCEDURE GetLogMessage@18(Text@1000 : Text) : Text;
    VAR
      Env@1001 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      String@1002 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String";
    BEGIN
      String := Text;
      EXIT(String.Replace('\',Env.NewLine));
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50082 Event Log Binder - File
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:21:32;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SingleInstance=Yes;
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      Module@1000 : Codeunit 50083;
      Name@1001 : TextConst 'ENU=File System Event Log';
      ImplementsInterface@1002 : TextConst 'ENU=Event Logging';

    [EventSubscriber(Codeunit,50060,OnBindModule)]
    LOCAL PROCEDURE BindModule@1(InterfaceName@1002 : Text;ModuleName@1001 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      CLEAR(Module);
      BINDSUBSCRIPTION(Module);
    END;

    [EventSubscriber(Codeunit,50060,OnUnbindModule)]
    LOCAL PROCEDURE UnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      UNBINDSUBSCRIPTION(Module);
      CLEAR(Module);
    END;

    [EventSubscriber(Table,50061,OnRegisterModule)]
    LOCAL PROCEDURE OnRegisterModule@3(InterfaceName@1000 : Text;VAR InterfaceModule@1001 : Record 50061);
    BEGIN
      IF InterfaceName = ImplementsInterface THEN
        InterfaceModule.RegisterModule(InterfaceName,Name,PAGE::"Event Log - File Setup");
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50083 Event Log - File
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:22:41];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    EventSubscriberInstance=Manual;
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50070,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@2(VAR EventLogArgs@1007 : Record 50010);
    VAR
      Setup@1003 : Record 50082;
      File@1004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
      Environment@1005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      EntryLine@1006 : TextConst 'ENU=%1 %2 %3%4';
    BEGIN
      IF NOT Setup.GET OR (Setup."Log File Path" = '') THEN
        EXIT;

      File.AppendAllText(
        Setup."Log File Path",
        STRSUBSTNO(
          EntryLine,
          CURRENTDATETIME,
          PADSTR(EventLogArgs.Source,20),
          EventLogArgs.Message,
          Environment.NewLine));
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50084 Event Log Binder - Twitter
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:21:48;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SingleInstance=Yes;
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      Module@1000 : Codeunit 50085;
      Name@1001 : TextConst 'ENU=Twitter Event Log';
      ImplementsInterface@1002 : TextConst 'ENU=Event Logging';

    [EventSubscriber(Codeunit,50060,OnBindModule)]
    LOCAL PROCEDURE BindModule@1(InterfaceName@1002 : Text;ModuleName@1001 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      CLEAR(Module);
      BINDSUBSCRIPTION(Module);
    END;

    [EventSubscriber(Codeunit,50060,OnUnbindModule)]
    LOCAL PROCEDURE UnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      UNBINDSUBSCRIPTION(Module);
      CLEAR(Module);
    END;

    [EventSubscriber(Table,50061,OnRegisterModule)]
    LOCAL PROCEDURE OnRegisterModule@3(InterfaceName@1000 : Text;VAR InterfaceModule@1001 : Record 50061);
    BEGIN
      IF InterfaceName = ImplementsInterface THEN
        InterfaceModule.RegisterModule(InterfaceName,Name,PAGE::"Event Log - Twitter Setup");
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50085 Event Log - Twitter
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:23:26];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    EventSubscriberInstance=Manual;
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50070,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@1(VAR EventLogArgs@1004 : Record 50010);
    VAR
      Setup@1005 : Record 50084;
      Twitter@1003 : DotNet "'Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.Twitter.TwitterApi";
    BEGIN
      IF (NOT Setup.GET) OR (Setup."Consumer Key" = '') OR (Setup."Consumer Key Secret" = '')
        OR (Setup."Access Token" = '') OR (Setup."Access Token Secret" = '')
      THEN
        EXIT;

      Twitter := Twitter.TwitterApi(
        Setup."Consumer Key",
        Setup."Consumer Key Secret",
        Setup."Access Token",
        Setup."Access Token Secret");

      Twitter.Tweet(
        GetEventMessage(
          EventLogArgs.Type,
          EventLogArgs.Source,
          EventLogArgs.Message));
    END;

    LOCAL PROCEDURE GetEventMessage@5(EventType@1002 : 'Info,Warning,Error';EventSource@1001 : Text;EventMessage@1000 : Text) : Text;
    VAR
      HashTags@1003 : Text;
    BEGIN
      HashTags := GetHashTags(EventType,EventSource);
      EXIT(COPYSTR(EventMessage,1,139 - STRLEN(HashTags)) + ' ' + HashTags);
    END;

    LOCAL PROCEDURE GetHashTags@2(EventType@1001 : 'Info,Warning,Error';EventSource@1000 : Text) HashTags : Text;
    VAR
      HashTagsText@1002 : TextConst 'ENU=#FromNAV #Demo #%1';
    BEGIN
      HashTags := STRSUBSTNO(HashTagsText,EventSource);
      IF EventType <> EventType::Info THEN
        HashTags += STRSUBSTNO(' #%1',EventType);
    END;

    BEGIN
    END.
  }
}

OBJECT Page 50060 Interface Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:00:11;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    InsertAllowed=No;
    DeleteAllowed=No;
    SourceTable=Table50060;
    PageType=List;
    OnOpenPage=BEGIN
                 OnRegisterInterface(Rec);
               END;

    OnAfterGetCurrRecord=BEGIN
                           SetupActive := "Configuration Page ID" <> 0;
                         END;

    ActionList=ACTIONS
    {
      { 8       ;    ;ActionContainer;
                      ActionContainerType=ActionItems }
      { 9       ;1   ;Action    ;
                      Ellipsis=Yes;
                      CaptionML=ENU=Setup;
                      Promoted=Yes;
                      Enabled=SetupActive;
                      PromotedIsBig=Yes;
                      Image=Setup;
                      PromotedCategory=Process;
                      OnAction=BEGIN
                                 Setup();
                               END;
                                }
    }
  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=Group;
                GroupType=Repeater }

    { 3   ;2   ;Field     ;
                SourceExpr="Interface Name" }

    { 4   ;2   ;Field     ;
                SourceExpr="Module Name";
                OnLookup=VAR
                           Lookup@1000 : Page 50061;
                         BEGIN
                           TESTFIELD("Interface Name");
                           Lookup.SetInterface("Interface Name");
                           Lookup.LOOKUPMODE := TRUE;
                           IF Lookup.RUNMODAL = ACTION::LookupOK THEN BEGIN
                             Lookup.GetModuleInfo("Module Name","Configuration Page ID");
                             CurrPage.UPDATE(TRUE);
                           END;
                         END;
                          }

    { 5   ;0   ;Container ;
                ContainerType=FactBoxArea }

    { 7   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=RecordLinks }

    { 6   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=Notes }

  }
  CODE
  {
    VAR
      SetupActive@1000 : Boolean;

    LOCAL PROCEDURE Setup@2();
    BEGIN
      PAGE.RUNMODAL("Configuration Page ID");
    END;

    BEGIN
    END.
  }
}

OBJECT Page 50061 Interface Module Lookup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:47:07;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SourceTable=Table50061;
    PageType=List;
    SourceTableTemporary=Yes;
    OnOpenPage=BEGIN
                 OnRegisterModule(InterfaceName,Rec);
               END;

  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=Group;
                GroupType=Repeater }

    { 3   ;2   ;Field     ;
                SourceExpr="Module Name" }

  }
  CODE
  {
    VAR
      InterfaceName@1000 : Text;

    PROCEDURE SetInterface@1(InterfaceNameIn@1000 : Text);
    BEGIN
      InterfaceName := InterfaceNameIn;
    END;

    PROCEDURE GetModuleInfo@3(VAR ModuleName@1000 : Text;VAR PageID@1001 : Integer);
    BEGIN
      ModuleName := "Module Name";
      PageID := "Configuration Page ID";
    END;

    BEGIN
    END.
  }
}

OBJECT Page 50082 Event Log - File Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:40:02;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    InsertAllowed=No;
    DeleteAllowed=No;
    SourceTable=Table50082;
    PageType=Card;
    OnOpenPage=BEGIN
                 IF NOT GET THEN
                   INSERT;
               END;

  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=General;
                GroupType=Group }

    { 3   ;2   ;Field     ;
                AssistEdit=Yes;
                SourceExpr="Log File Path";
                OnAssistEdit=VAR
                               Dlg@1000 : Codeunit 419;
                             BEGIN
                               "Log File Path" := Dlg.SaveFileDialog(DialogTitle,'EventLog.txt',Filter);
                             END;
                              }

    { 6   ;0   ;Container ;
                ContainerType=FactBoxArea }

    { 5   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=RecordLinks }

    { 4   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=Notes }

  }
  CODE
  {
    VAR
      DialogTitle@1000 : TextConst 'ENU=Event Log File';
      Filter@1001 : TextConst 'ENU=Text files (*.txt)|*.txt';

    BEGIN
    END.
  }
}

OBJECT Page 50084 Event Log - Twitter Setup
{
  OBJECT-PROPERTIES
  {
    Date=28.09.16;
    Time=22:01:04;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    InsertAllowed=No;
    DeleteAllowed=No;
    SourceTable=Table50084;
    PageType=Card;
    OnOpenPage=BEGIN
                 IF NOT GET THEN
                   INSERT;
               END;

  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=General;
                GroupType=Group }

    { 3   ;2   ;Field     ;
                SourceExpr="Consumer Key" }

    { 4   ;2   ;Field     ;
                SourceExpr="Consumer Key Secret" }

    { 5   ;2   ;Field     ;
                SourceExpr="Access Token" }

    { 6   ;2   ;Field     ;
                SourceExpr="Access Token Secret" }

    { 7   ;0   ;Container ;
                ContainerType=FactBoxArea }

    { 8   ;1   ;Part      ;
                PartType=System;
                SystemPartID=RecordLinks }

    { 9   ;1   ;Part      ;
                PartType=System;
                SystemPartID=Notes }

  }
  CODE
  {

    BEGIN
    END.
  }
}

